package info.yaohua;

import info.bean.Ac03;
import info.bean.Ac04;
import info.dao.Ac02Dao;
import info.dao.Ac03Dao;
import info.util.SessionNull;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.naming.NamingException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class Yuan_gl_Servlet extends HttpServlet
	{
		@Override
		protected void doGet(HttpServletRequest req, HttpServletResponse resp)
				throws ServletException, IOException
			{
				// TODO Auto-generated method stub
				HttpSession session=req.getSession(false);
				if(session==null)
					{
						SessionNull.forwordTo(req, resp);
					}
				else
					{
						Ac04 ac04 = (Ac04) session.getAttribute("ac04");
						int y_id = ac04.getY_id();
						Ac03Dao ac03Dao= new Ac03Dao();
						try
							{
								ArrayList list_ac03 = ac03Dao.findAc03ByY_id(y_id);
								int count=list_ac03.size()-1;
								req.setAttribute("count", count);
								req.setAttribute("list_ac03", list_ac03);
								RequestDispatcher view= req.getRequestDispatcher("/glxld.jsp");
								view.forward(req, resp);
							}
						catch (NamingException | SQLException e)
							{
								// TODO Auto-generated catch block
								e.printStackTrace();
							} 
					}
			}

		@Override
		protected void doPost(HttpServletRequest req, HttpServletResponse resp)
				throws ServletException, IOException
			{
				// TODO Auto-generated method stub
				super.doPost(req, resp);
			}
	}
